<?php

namespace App\Models\Admin\Stats\Risk;

use App\Models\Admin\Model;
use App\Models\Traits\Admin\LogsActivity;

class Config extends Model
{
    use  LogsActivity;

    /**
     * 数据表名称
     *
     * @var string
     */
    protected $table = 'stats_risk_config';

    /**
     * 不可批量赋值的属性
     *
     * @var array
     */
    protected $guarded = [];

    /**
     * 进行类型转换的字段
     *
     * @var array
     */
    protected $casts = [
        'config' => 'array',
    ];

    /**
     * 类型【SLO】
     */
    const TYPE_SLO = 'slo';

    /**
     * 获取配置
     *
     * @param $type
     * @return array
     */
    protected function getCofing($type)
    {
        $data = $this->newQuery()->where('type', $type)->first();

        return !is_null($data) ? $data->config : [
            'player' => [], 'game' => [], 'orgGame' => []
        ];
    }
}
